package com.juyu.miliao.api.controller;

import com.juyu.miliao.api.service.GameDataService;
import com.juyu.miliao.common.domain.Subject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDate;

/**
 * @author jh
 * @date 2019/09/19
 */
@RestController
@RequestMapping(value = "/stat/game-hall")
@Api(tags = "游戏中心统计")
public class GameHallStatController {

    @Resource
    private GameDataService gameDataService;

    @PutMapping(value = "/visit-num")
    @ApiOperation(value = "统计访客", notes = "登陆")
    public void addVisit(Authentication token) {
        Subject subject = (Subject) token.getPrincipal();
        Long userId = subject.getId();
        gameDataService.increaseGameVisitNum(LocalDate.now(), userId);
        gameDataService.increaseGameVisitNumAll(userId);
    }


}
